package com.remotebluetooth;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import javax.microedition.io.StreamConnection;

public class BlueToothCMD extends Thread {
	
	private StreamConnection mConnection;
	
	public BlueToothCMD(StreamConnection connection)
	{
		mConnection = connection;
		start();
	}
	
	@Override
	public void run() {
		try{
			OutputStream outStream=mConnection.openOutputStream();
		
			while(true){
				try {
					if(System.in.available()>0){
						BufferedReader in = new BufferedReader( new InputStreamReader( System.in ));
						String InLine = in.readLine();
						InLine+="\r\n";
						byte[] buf=InLine.getBytes();
						System.out.print(buf);
						outStream.write(buf);
						outStream.write(buf);
					}
					
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}catch (Exception e) {
    		e.printStackTrace();
    	}
	}

}
